<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="../css/sousuo1.css"/>
</head>
<body>
    
    <header class="header">
        <div class="search">
            <img src="../imgs/sousuo%20(2).png"/>
            <input list="list" id="input_one" type="text" placeholder="搜服务"/>
            <img src="../imgs/sousuo%20(1).png"/>
        </div>
        <p>取消</p>
    </header>
    
    <section class="sec">
        <datalist id="list">
            <option>融合账单</option>
            <option>水账单</option>
        </datalist>
    </section>
    
    <footer class="fot">
        <div id="btn" class="qingchu">
            清除搜索记录
        </div>
    </footer>
    
    
    <script src="../js/flexible.debug.js"></script>
    <script src="../js/flexible_css.debug.js"></script>
    <script src="../js/jquery-1.12.4.min.js"></script>
    <script>
        $(function($){
        function set(val,name){
            localStorage.setItem(val,name);
        };
        function get(name){
            return localStorage.getItem(name);
        };
    $("#input_one").keydown(function(e){
        
       var value = $("#input_one").val()
        if(e.keyCode==13){
            var obj ={
                "name":value
                
            }
            //alert(1)
             var value = $("#input_one").val("")
            var infos = get("infos");
            if(infos){
                infos = JSON.parse(infos)
                infos.push(obj)
                 set("infos",JSON.stringify(infos))
            }else{
                set("infos",JSON.stringify([obj]))
                
            }
            
            
        }
        
        
    })
    //入口函数
    var infos =get("infos");
         var str = ""; 
     infos = JSON.parse(infos)        
      if(infos){
          $.each(infos,function(i,n){
               concat =   n.name;
               str+= "<option>" +concat+ "</option>";
          })
          
         
          $("#list").append(str)
      }        
     
    $("#btn").click(function(){
        
        localStorage.clear();
    })
    
    
        })
    </script>
</body>
</html>